<template>
	<view class="box-content-f" @click.stop="itemClick">
			<view class="box-f-list">
				<view class="record-content">
					<view class="time">
						<span>饮食时间</span>：{{formatTime()}}
					</view>
					<view class="content">
						<span>主食</span>：{{formatContent()}}
					</view>
					<view class="content">
					    <span>食量</span>：{{formatFoodQuantity(record.quantity)}}
					</view>
				</view>
				<LmageListView style="margin-top: 10rpx;"
					:resourceUrls="record.medias | resourceUrlFilter" />
			</view>
			<view v-if="state">
				<div class="box-icon-f">
					<u-icon name="arrow-right"></u-icon>
				</div>
			</view>
	</view>
</template>

<script>
	// import MultiMediaView from '@/components/multi-media-view.vue'
	import LmageListView from '@/components/image-list-view.vue'
	import { formatDateByTimestamp } from '@/utils/utils.js'
	export default {
		name: "Food",
		components: {
			// MultiMediaView,
			LmageListView
		},
		props: {
			record: {
				type: Object,
				default () {
					return null;
				}
			},
			state: {
				type: Boolean,
				default: false
			}
		},
		filters: {
			resourceUrlFilter (value) {
				if (!value) {
					return []
				}
				return value.split('|');
			}
		},
		data() {
			return {
	
			};
		},
		methods:{
			formatTime() {
				return formatDateByTimestamp(this.record.eventTime, 'hh:MM');
			},
			
			formatContent() {
				return `${this.record.food??''}`;
				// return `${this.record.food??''}｜${this.formatFoodQuantity(this.record.quantity)}`;
			},
			
			formatFoodQuantity (quantity) {
				if (quantity === 0) {
					return '正常';
				} else if (quantity === 1) {
					return '量少';
				} else if (quantity === 2) {
					return '量多';
				}
			},
			
			itemClick() {
				this.$emit('itemClick')
			}
		}
	}
</script>

<style lang="scss">
	.box-content-f{
		display: flex;
		align-items: center;
		justify-content: space-between;
		margin: 20rpx 35rpx;
		background: #ffffff;
		line-height: 59rpx;
		padding: 20rpx 20rpx;
		border-bottom: 1rpx solid #F5F5F5;
	}
	
	.box-f-list {
		width: 100%;
		padding-left: 20rpx;
		padding-right: 20rpx;
		span {
			color: #999999;
		}

			

	}
	.box-icon-f{
		font-size: 30rpx;
	}
</style>
